<template>
  <div class="wrap">
    <div class="img-box">
      <img :src="`/api${item.cover}`" alt="" />
    </div>
    <div class="text">
      <p>{{ item.name }}</p>
    </div>
    <div class="price">
      <span>$</span>
      {{ item.price }}
    </div>
    <button class="edit" :id="item._id">编辑</button>
    <button class="delete" @click="del" :id="item._id">删除</button>
  </div>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      required: true
    }
  },
  methods: {
    del(e) {
      this.$emit('del', e.target.id)
    }
  }
}
</script>

<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
}
.wrap {
  width: 100%;
  height: 120px;
  margin: 15px 0;
  background-color: #fff;
  opacity: 0.8;
  border-radius: 10px;
  backdrop-filter: blur(10px);
  background: url('../../assets/image/bg.jpg') no-repeat;

  display: flex;
  justify-content: space-around;
  align-items: center;
  &:hover {
    box-shadow: 8px 8px 10px rgba(#000, 0.7);
  }
  .img-box {
    img {
      width: 80px;
      height: 80px;
      object-fit: cover;
      transition: all 0.25s ease-out;
      &:hover {
        width: 100px;
        height: 100px;
        transition: all 0.15s ease-in;
      }
    }
  }
  .text {
    width: 200px;
    height: 40px;
    color: #fff;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    transition: all 0.25s ease-out;
    &:hover {
      width: 300px;
      height: 80px;
      font-size: 18px;
      transition: all 0.15s ease-in;
    }
  }
  .price {
    font-size: 20px;
    font-weight: 600;
    color: red;
  }
  .edit {
    background-color: green;
    transition: all 0.25s ease-out;
    &:active {
      background-color: rgba(green, 0.8);
      transform: scale(1.1);
      transition: all 0.15s ease-in;
    }
  }
  .delete {
    background-color: red;
    transition: all 0.25s ease-out;
    &:active {
      background-color: rgba(red, 0.8);
      transform: scale(1.1);
    }
  }
}
button {
  width: 60px;
  height: 25px;
  outline: none;
  border-radius: 4px;
  border: none;
  color: #fff;
}
</style>
